# views.py in 'video_records' app
from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework import status
from .models import VideoRecord
from .serializers import VideoRecordSerializer

class VideoRecordList(APIView):
    def get(self, request, *args, **kwargs):
        # 可选：可以添加过滤条件，比如时间范围
        video_records = VideoRecord.objects.all()
        serializer = VideoRecordSerializer(video_records, many=True)
        return Response(serializer.data)

class VideoRecordDetail(APIView):
    def get(self, request, video_id, *args, **kwargs):
        try:
            video_record = VideoRecord.objects.get(video_id=video_id)
            serializer = VideoRecordSerializer(video_record)
            return Response(serializer.data)
        except VideoRecord.DoesNotExist:
            return Response({'error': 'Video Record not found'}, status=status.HTTP_404_NOT_FOUND)
